﻿' Copyright (C) 2011  Jan-Willem de Bruyn
'
'    This program is free software: you can redistribute it and/or modify
'    it under the terms of the GNU General Public License as published by
'    the Free Software Foundation, either version 3 of the License, or
'    (at your option) any later version.
'
'    This program is distributed in the hope that it will be useful,
'    but WITHOUT ANY WARRANTY; without even the implied warranty of
'    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'    GNU General Public License for more details.
'
'    You should have received a copy of the GNU General Public License
'    along with this program.  If not, see <http://www.gnu.org/licenses/>.

Public Class calc
    Inherits System.Web.UI.Page
    Dim num As Integer = -1
    Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles DropDownList1.SelectedIndexChanged
        If DropDownList1.SelectedValue = "exp" Then
            TextBox4.Text = Math.Exp(CInt(TextBox3.Text))
            num = 0
        ElseIf DropDownList1.SelectedIndex = 1 Then
            TextBox4.Text = Math.Log(CInt(TextBox3.Text))
            num = 1
        End If
    End Sub

    Protected Sub TextBox3_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles TextBox3.TextChanged
        If num >= 0 Then
            If num = 0 Then
                TextBox4.Text = Math.Exp(TextBox3.Text)
            ElseIf num = 1 Then
                TextBox4.Text = Math.Log(TextBox3.Text)
            End If
        End If
    End Sub
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        If DropDownList1.SelectedIndex = 0 Then
            TextBox4.Text = Math.Exp(CInt(TextBox3.Text))
            num = 0
        ElseIf DropDownList1.SelectedIndex = 1 Then
            TextBox4.Text = Math.Log(CInt(TextBox3.Text))
            num = 1
        ElseIf DropDownList1.SelectedIndex = 2 Then
            TextBox4.Text = Math.Sin(CInt(TextBox3.Text))
            num = 2
        ElseIf DropDownList1.SelectedIndex = 3 Then
            TextBox4.Text = Math.Tan(CInt(TextBox3.Text))
            num = 2
        End If
    End Sub
End Class